package com.ccc.scala.base7_collection

import scala.collection.mutable.ArrayBuffer


object Collection08_SortBy {
  def main(args: Array[String]): Unit = {
    // 集合 - sortBy

    val arr = ArrayBuffer("11", "12", "111", "25", "233")

    println(arr.sortBy(str => str)) // ArrayBuffer(11, 111, 12, 233, 25)
    println(arr.sortBy(str => str.toInt)) // ArrayBuffer(11, 12, 25, 111, 233)

    // 指定逆序 使用函数Curry化
    println(arr.sortBy(str => str.toInt)(Ordering.Int.reverse)) // ArrayBuffer(233, 111, 25, 12, 11)

  }

}
